<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="box">
    {{text}}---{{val}}
    <br>
    <!--使用表单input事件,获取表单的输入值-->
    <!--然后使用bind,双向绑定表单-->
    <input type="text" @input="input" :value="val">
  </div>

  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>

  <script>


    const vm = new Vue({
      el: '#box',
      data: {
        text: 'hello Vue',
        val: ''
      },
      methods: {
        input(e) {
          // console.log(this.val); 
          // console.log(e.target.value);
          this.val = e.target.value
        }
      }
    })




  </script>

</body>

</html>